package com.qfedu.controller;


import com.qfedu.fmmall.service.UserService;
import com.qfedu.fmmall.vo.ResultStatus;
import com.qfedu.fmmall.vo.ResultVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@CrossOrigin //允许跨域
@RestController
@RequestMapping("/user")
@Api(value = "用户登录和注册功能",tags = "登录注册")
public class UserController {

    /**
     * 用户登录注册接口
     * @Author Liux8
     * */

    @Resource
    private UserService userService;


    @ApiOperation("用户登录")
    @ApiImplicitParams({
                @ApiImplicitParam(dataType = "string",name = "username",value="用户账号",required = true),
                @ApiImplicitParam(dataType = "string",name="password",value = "用户密码",required = true)
    })
    @GetMapping(value = "/login")
    public ResultVo Login(String username,String password){

        return userService.checkLogin(username,password);
    }
    @ApiOperation("用户注册")
    @PostMapping("/resgist")
    @ApiImplicitParams({
            @ApiImplicitParam(dataType = "string",name = "username",value="用户账号",required = true),
            @ApiImplicitParam(dataType = "string",name="password",value = "用户密码",required = true)
    })
    public ResultVo regist(String username,String password){
        return userService.userResgit(username,password);
    }

    @ApiOperation("用户数据")
    @GetMapping("userInfo")
    public ResultVo getUserlist(){
        return null;
    }

    @GetMapping("userById/{uid}")
    public ResultVo userById(@PathVariable("uid")String userId){
        System.out.println("运行成功了哦---------------<>");
        return null;
    }
    @ApiOperation("验证token")
    @GetMapping("check")
    public ResultVo checkToken(@RequestHeader("token")String token){
        return new ResultVo(ResultStatus.OK,"success",null);
    }
}
